package com.yanyeori.framework.datasource.configprop;

import com.yanyeori.framework.datasource.builder.DruidDataSourceBuilder;
import com.yanyeori.framework.datasource.builder.HikariDataSourceBuilder;
import com.zaxxer.hikari.HikariDataSource;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import javax.sql.DataSource;
import java.util.List;

/**
 * 多数据源配置
 *
 * @author chenkuan 2020/8/6
 */
@Getter
@Setter
@ConfigurationProperties(prefix = "spring.datasource")
public class DataSourceConfigProps {
    private Class<? extends DataSource> type = HikariDataSource.class;
    private String name;
    private String url;
    private String username;
    private String password;
    private String driverClassName;

    @NestedConfigurationProperty
    private DruidDataSourceBuilder.DruidConfigProps druid = new DruidDataSourceBuilder.DruidConfigProps();

    @NestedConfigurationProperty
    private HikariDataSourceBuilder.HikariConfigProps hikari = new HikariDataSourceBuilder.HikariConfigProps();

    @NestedConfigurationProperty
    private List<MultiDataSourceConfigProps> list;

    @NestedConfigurationProperty
    private List<RouterProps> routers;

    @NestedConfigurationProperty
    private ConfigProps config = new ConfigProps();
}
